<?php

namespace app\admin\Controller;

use app\admin\model\Article_CategoryModel;
use app\admin\Model\ArticleModel;
use cmf\controller\AdminBaseController;
use think\db\Where;

class IndexnewController extends AdminBaseController
{
    protected $autoWriteTimestamp = true;
    public function index(){
        extract(input());
        $where = new Where;
        if(isset($category_id) && !empty($category_id)){
            $where['category_id'] = ['like','%'.$category_id.'%'];
        }
        $data = ArticleModel::where($where)->select();
        $category = Article_CategoryModel::all();
        //halt($category);

        return $this->fetch('index',[
            'data' => $data,
            'category' => $category
        ]);
    }



    public function news(){
        $id = input('art_id');
        $data = ArticleModel::where('art_id',$id)->find();

        return $this->fetch('news',[
            'data' => $data
        ]);
    }
}